#!/usr/bin/python3
# -*- coding: utf-8 -*-
import requests
from testFile import read_yaml
import json


def requests_public(args):
    domainName = read_yaml.readYaml()['domainName']['域名']
    headers = read_yaml.readYaml()['headers']
    data = read_yaml.readYaml()['data']
    # if len(args) == 1:  # args传递的一个字典，长度为1时是路由，长度大于1时包含其他必传递参数
    #     pass
    # else:
    #     for num in range(1, len(args)):  # 遍历字典中第二个到最后一个元素，然后添加到data
    #         data[list(args)[num]] = args[list(args)[num]]
    route = args['route']
    del args['route']
    data.update(args)
    url = str(domainName) + str(route)
    # print(data)
    rep = requests.post(url, json.dumps(data), headers=headers)
    res = rep.json()
    return res
